//package com.easipass.business.service.impl;
//
//import com.easipass.business.constant.BusinessCode;
//import com.easipass.business.dto.page.ResourcePageDTO;
//import com.easipass.business.dto.save.ResourceSaveDTO;
//import com.easipass.business.dto.transfer.ResourceTransfer;
//import com.easipass.business.dto.vo.ResourceVO;
//import com.easipass.business.exception.BusinessException;
//import com.easipass.business.po.ResourcePO;
//import com.easipass.business.repository.ResourceMockDao;
//import com.easipass.business.service.ResourceService;
//import com.easipass.commons.lang.text.StringUtils;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Date;
//import java.util.List;
//
//@Service
//@Transactional
//public class ResourceServiceImpl implements ResourceService {
//
//    @Autowired
//	ResourceMockDao resourceMockDao;
//
//    @Override
//    public ResourceVO getResourceVOByResourceName(String resourceName) {
//        return ResourceTransfer.po2Vo(resourceMockDao.getByResourceName(resourceName));
//    }
//
//    @Override
//    public int deleteByResourceName(String resourceName) {
//        return resourceMockDao.deleteByResourceName(resourceName);
//    }
//
//    @Override
//    public ResourceVO save(ResourceSaveDTO resourceSaveDTO) {
//        if(null == resourceSaveDTO){
//            throw new BusinessException(BusinessCode.CODE_500001);
//        }
//        ResourcePO resourcePO = ResourceTransfer.dto2Po(resourceSaveDTO);
//        Date now = new Date();
//        if(StringUtils.isEmpty(resourcePO.getResourceName())){
//            //insert
//            resourcePO.setResourceName("xxx");
//            resourcePO.setCreateTime(now);
//            resourcePO.setModifyTime(now);
//            return ResourceTransfer.po2Vo(resourceMockDao.save(resourcePO));
//        }else {
//            ResourcePO resourcePO_old = resourceMockDao.getByResourceName(resourceSaveDTO.getResourceName());
//            //update
//            if(null == resourcePO_old){
//                throw new BusinessException(BusinessCode.CODE_500002);
//            }
//            BeanUtils.copyProperties(resourceSaveDTO, resourcePO_old);
//            resourcePO_old.setModifyTime(now);
//            return ResourceTransfer.po2Vo(resourceMockDao.save(resourcePO_old));
//        }
//    }
//
//    @Override
//    public int count(ResourcePageDTO resourcePageDTO) {
//        return resourceMockDao.count(resourcePageDTO);
//    }
//
//    @Override
//    public List<ResourceVO> page(ResourcePageDTO resourcePageDTO, int count) {
//        List<ResourcePO> resourcePOList = resourceMockDao.page(resourcePageDTO);
//        return ResourceTransfer.po2Vo(resourcePOList);
//    }
//
//    @Override
//    public List<ResourceVO> getListByResourceType(String resourceType) {
//        return ResourceTransfer.po2Vo(resourceMockDao.getListByResourceType(resourceType));
//    }
//
//    @Override
//    public int updateResourceStatus(String resourceName, Integer resourceStatus) {
//        return resourceMockDao.updateResourceStatus(resourceName , resourceStatus);
//    }
//}
